/**
 * futures : masterlink.futures.vo.FutpabReal.java
 */
package masterlink.futures.vo;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Embeddable;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;

/**
 * TODO Write the description
 *
 * @author : tonyyang
 * Create date : 2011/11/8
 * @version 1.0.0	
 */
@Entity
public class FutpabRealSum implements Serializable{

	private static final long serialVersionUID = -7837804127952914715L;
	
	@EmbeddedId
	private Id id;
	@Column(name="quantity")
	private Integer quantity;
	@Column(name="avgprice")
	private Double avgPrice;
	
	/* (non-Javadoc)
	 * @see java.lang.Object#hashCode()
	 */
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		return result;
	}

	/* (non-Javadoc)
	 * @see java.lang.Object#equals(java.lang.Object)
	 */
	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (!(obj instanceof FutpabRealSum))
			return false;
		FutpabRealSum other = (FutpabRealSum) obj;
		if (id == null) {
			if (other.id != null)
				return false;
		} else if (!id.equals(other.id))
			return false;
		return true;
	}

	/* (non-Javadoc)
	 * @see java.lang.Object#toString()
	 */
	@Override
	public String toString() {
		StringBuilder builder = new StringBuilder();
		builder.append("FutpabRealSum [id=");
		builder.append(id);
		builder.append(", quantity=");
		builder.append(quantity);
		builder.append(", avgPrice=");
		builder.append(avgPrice);
		builder.append("]");
		return builder.toString();
	}

	/**
	 * @return the id
	 */
	public Id getId() {
		return id;
	}

	/**
	 * @param id the id to set
	 */
	public void setId(Id id) {
		this.id = id;
	}

	/**
	 * @return the quantity
	 */
	public Integer getQuantity() {
		return quantity;
	}

	/**
	 * @param quantity the quantity to set
	 */
	public void setQuantity(Integer quantity) {
		this.quantity = quantity;
	}

	/**
	 * @return the avgPrice
	 */
	public Double getAvgPrice() {
		return avgPrice;
	}

	/**
	 * @param avgPrice the avgPrice to set
	 */
	public void setAvgPrice(Double avgPrice) {
		this.avgPrice = avgPrice;
	}

	@Embeddable
	public static class Id implements Serializable{
		
		private static final long serialVersionUID = -3016332596415044064L;
		@Column(name="trid")
		private String trid;
		@Column(name="buysell")
		private String buySell;
		/**
		 * @return the trid
		 */
		public String getTrid() {
			return trid;
		}
		/**
		 * @param trid the trid to set
		 */
		public void setTrid(String trid) {
			this.trid = trid;
		}
		/**
		 * @return the buySell
		 */
		public String getBuySell() {
			return buySell;
		}
		/**
		 * @param buySell the buySell to set
		 */
		public void setBuySell(String buySell) {
			this.buySell = buySell;
		}
		/* (non-Javadoc)
		 * @see java.lang.Object#toString()
		 */
		@Override
		public String toString() {
			StringBuilder builder = new StringBuilder();
			builder.append("Id [trid=");
			builder.append(trid);
			builder.append(", buySell=");
			builder.append(buySell);
			builder.append("]");
			return builder.toString();
		}
		/* (non-Javadoc)
		 * @see java.lang.Object#hashCode()
		 */
		@Override
		public int hashCode() {
			final int prime = 31;
			int result = 1;
			result = prime * result
					+ ((buySell == null) ? 0 : buySell.hashCode());
			result = prime * result + ((trid == null) ? 0 : trid.hashCode());
			return result;
		}
		/* (non-Javadoc)
		 * @see java.lang.Object#equals(java.lang.Object)
		 */
		@Override
		public boolean equals(Object obj) {
			if (this == obj)
				return true;
			if (obj == null)
				return false;
			if (!(obj instanceof Id))
				return false;
			Id other = (Id) obj;
			if (buySell == null) {
				if (other.buySell != null)
					return false;
			} else if (!buySell.equals(other.buySell))
				return false;
			if (trid == null) {
				if (other.trid != null)
					return false;
			} else if (!trid.equals(other.trid))
				return false;
			return true;
		}
		
	}
}
